package com.aipartner.mapper;

import com.aipartner.entity.CreditsOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 积分订单 Mapper 接口
 *
 * @author AI Partner
 * @since 2025-09-18
 */
@Mapper
public interface CreditsOrderMapper extends BaseMapper<CreditsOrder> {

    /**
     * 分页查询用户积分订单
     */
    @Select("SELECT * FROM credits_orders WHERE user_id = #{userId} ORDER BY create_time DESC")
    IPage<CreditsOrder> selectByUserIdPage(Page<?> page, @Param("userId") Long userId);

    /**
     * 根据订单号查询订单
     */
    @Select("SELECT * FROM credits_orders WHERE order_no = #{orderNo}")
    CreditsOrder selectByOrderNo(@Param("orderNo") String orderNo);
}
